#ifndef _KEY_H_
#define _KEY_H_

#include "Global.h"
#include "SC_GPIO.h"
#include "Config.h"
//---- ����IO�ڶ��� ----//

#define P_L1    DEF_PIN(B,2)
#define M_L1    DEF_PIN_DIR(B, 2)
#define WPU_L1  DEF_PIN_WPU(B, 2)


#define P_L2    DEF_PIN(A,5)
#define M_L2    DEF_PIN_DIR(A, 5)
#define WPU_L2  DEF_PIN_WPU(A, 5)


#define P_L3    DEF_PIN(B,7)
#define M_L3    DEF_PIN_DIR(B, 7)
#define WPU_L3  DEF_PIN_WPU(B, 7)


#define P_L4    DEF_PIN(B,5)
#define M_L4    DEF_PIN_DIR(B, 5)
#define WPU_L4  DEF_PIN_WPU(B, 5)


#define P_R1    DEF_PIN(A,0)
#define M_R1    DEF_PIN_DIR(A, 0)
#define WPU_R1  DEF_PIN_WPU(A, 0)

#define P_R2    DEF_PIN(A,1)
#define M_R2    DEF_PIN_DIR(A, 1)
#define WPU_R2  DEF_PIN_WPU(A, 1)

#define P_R3    DEF_PIN(A,2)
#define M_R3    DEF_PIN_DIR(A, 2)
#define WPU_R3  DEF_PIN_WPU(A, 2)

#define P_R4    DEF_PIN(A,3)
#define M_R4    DEF_PIN_DIR(A, 3)
#define WPU_R4  DEF_PIN_WPU(A, 3)

#define P_R5    DEF_PIN(A,4)
#define M_R5    DEF_PIN_DIR(A, 4)
#define WPU_R5  DEF_PIN_WPU(A, 4)


#define SET_IN(pin)      do{P_##pin = 1;  M_##pin = 1; WPU_##pin = 1;} while(0)
#define SET_OUT(pin,hl)  do{P_##pin = hl; M_##pin = 0; WPU_##pin = 0;} while(0)
#define GET_PIN(pin)    P_##pin

enum
{
    KEY1 = 0,
    KEY2 ,
    KEY3 ,
    KEY4 ,
    KEY5 ,
    KEY6 ,
    KEY7 ,
    KEY8 ,
    KEY9 ,
    KEY10 ,
    KEY11 ,
    KEY12 ,
    KEY13 ,
    KEY14 ,
    KEY15 ,
    KEY16 ,
    KEY_COMBO1,         //  ��ϼ� 1 - ����ң����
    KEY_COMBO2,         //  ��ϼ� 2 - ���ù���ģʽ
};




#define	TM_DBC_KEY		10      //---- ����ʱ��
#define C_MAX_KEY_PRESS 2       //---- ���2��
#define C_MAX_KEY_NUM   18      //---- ����������������ϼ���
#define INVAILD_KEY     0xFF    //---- ��Ч����

// extern void(*KeyShortFunc[18])(void);
// extern void(*KeyLongFunc[18])(void);

extern uint8 RKeyCode;


void initKEY(void);
void Key_PowerSaveSet(void);
void Key_Main(void);
void MultiKey_Proc(void);

#endif

